<template>
  <div style="background: #fff">
    <module-tabs class="yq-feedback" v-model="activeName" :tabs="tabs" is-flex-box>
      <template #first>
        <all-info />
      </template>
      <template #second>
        <div>
          <el-form :model="form" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
            <el-form-item label="批示" prop="ldps">
              <el-radio-group v-model="form.ldps">
                <el-radio label="1">同意</el-radio>
                <el-radio label="0">不同意</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="批示内容" prop="psnr">
              <el-input v-model="form.psnr" type="textarea" :row="3" maxlength="200" show-word-limit></el-input>
            </el-form-item>
            <el-button type="primary" @click="submitForm" :loading="loading">确认</el-button>
            <el-button @click="() => $router.go(-1)">取消</el-button>
          </el-form>
        </div>
      </template>
    </module-tabs>
  </div>
</template>
<script>
import AllInfo from '@/pages/ExterCommun/detail/components/AllInfo';
import ModuleTabs from '@/components/layout/module-tabs';

import { approval } from '@/api/submitReview';
export default {
  name: 'Approval',
  components: {
    ModuleTabs,
    AllInfo
  },
  data() {
    return {
      loading:false,
      tabs: [
        {
          label: '基本信息',
          name: 'first'
        },
        {
          label: '领导批示',
          name: 'second'
        }
      ],
      activeName: 'second',
      form: {
        ldps: '1',
        psnr: ''
      },
      rules: {
        ldps: [{ required: true, message: '请批示', trigger: 'blur' }]
      }
    };
  },
  methods: {
    submitForm() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          this.loading=true
          approval({ id: this.$route.params.sid, ...this.form })
            .then(() => {
              this.loading = false;
              this.$message.success('操作成功');
              this.$router.go(-1);
            })
            .catch(() => {
              this.loading = false;
              this.$message.warning('操作失败');
            });
        }
      });
    }
  }
};
</script>
